package com.liu.sx.controller;

import com.liu.sx.common.entity.PageResult;
import com.liu.sx.common.entity.Result;
import com.liu.sx.common.status.CodeEnum;
import com.liu.sx.entity.Worm;
import com.liu.sx.service.WormService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RequestMapping("/worm")
@RestController
public class WormController {

    @Autowired
    private WormService wormService;

    @GetMapping
    public Result List(int page,int rows,String query){
       Page<Worm> pages =  wormService.findPageByQuery(page ,rows,query);

       return  new Result(true, CodeEnum.OK.getCode(),"查询成功",new PageResult<Worm>(pages.getTotalElements(),pages.getContent()));
    }





}
